Skip to content

TDL-17512: Add missing tap-tester tests#134

Open
hpatel41 wants to merge 7 commits intocrest-workfrom
TDL-17512-add-missing-tap-tester-tests
Open

TDL-17512: Add missing tap-tester tests#134
hpatel41 wants to merge 7 commits intocrest-workfrom
TDL-17512-add-missing-tap-tester-tests

Conversation

@hpatel41
Copy link
Copy Markdown
Contributor

Description of change

TDL-17512: Add missing tap-tester tests

  • added all fields test
  • missing assertions in discovery, start date, bookmark test cases.

QA steps

  • automated tests passing
  • manual qa steps passing (list below)

Risks

Rollback steps

  • revert this branch

@hpatel41 hpatel41 changed the base branch from master to crest-work February 2, 2022 06:03
@savan-chovatiya savan-chovatiya marked this pull request as ready for review February 2, 2022 07:23
Comment thread tests/base.py Outdated
Comment on lines +135 to +139
# removed "abandoned_checkouts", as per the Doc:
# https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts
# abandoned checkouts are saved in the Shopify admin for three months.
# Every Monday, abandoned checkouts that are older than three months are removed from your admin.
return set(self.expected_metadata().keys()) - {"abandoned_checkouts"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments about the unavailability of the POST call with a reference link.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment in the test cases.

Comment thread tests/test_discovery.py
if md_entry['breadcrumb'] != []:
actual_fields.append(md_entry['breadcrumb'][1])
# Verify there are no duplicate/conflicting metadata entries.
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about this assertion at the function(test_run()) level comment above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition

Comment thread tests/test_start_date.py
target_mark = second_min_bookmarks.get(stream, {"mark": None})
target_value = next(iter(target_mark.values())) # there should be only one
# Verify by primary key values, that all records of the 2nd sync are included in the 1st sync since 2nd sync has a later start date.
self.assertTrue(primary_keys_sync_2.issubset(primary_keys_sync_1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about this assertion at the function(test_run()) level comment above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function comment.

Comment thread tests/test_start_date.py Outdated
Comment on lines +151 to +152
for start_date, target_mark in zip((first_sync_start_date, second_sync_start_date), (first_sync_target_mark, second_sync_target_mark)):
target_value = next(iter(target_mark.values())) # there should be only one
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here about the addition of for loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment.

@hpatel41 hpatel41 requested a review from savan-chovatiya March 4, 2022 05:41
Comment thread tests/test_all_fields.py Outdated
return return_value

@staticmethod
def get_credentials(original_credentials: bool = True):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already available in base.py, Any reason for redefining it?

Copy link
Copy Markdown
Contributor Author

@hpatel41 hpatel41 Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test case to use the function from base test file.

Comment thread tests/test_all_fields.py
Comment thread tests/test_start_date.py Outdated
@hpatel41 hpatel41 requested a review from dbshah1212 March 9, 2022 08:42
Copy link
Copy Markdown
Contributor

@kspeer825 kspeer825 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good work. I left one suggestion for the start date test. Also the abandoned_checkouts does not need to be removed. We periodically refresh that data using tooling outside of tap-tester.

Comment thread tests/base.py Outdated
Comment on lines +135 to +140
return set(self.expected_metadata().keys())
# removed "abandoned_checkouts", as per the Doc:
# https://help.shopify.com/en/manual/orders/abandoned-checkouts?st_source=admin&st_campaign=abandoned_checkouts_footer&utm_source=admin&utm_campaign=abandoned_checkouts_footer#review-your-abandoned-checkouts
# abandoned checkouts are saved in the Shopify admin for three months.
# Every Monday, abandoned checkouts that are older than three months are removed from your admin.
# Also no POST call is available for this endpoint: https://shopify.dev/api/admin-rest/2022-01/resources/abandoned-checkouts
return set(self.expected_metadata().keys()) - {"abandoned_checkouts"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this stream back, we have internal tooling for generating these records outside of the base test suite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included abandoned_checkouts stream

Comment thread tests/base.py Outdated
self.start_date = self.get_properties().get("start_date")
self.store_1_streams = {'custom_collections', 'orders', 'products', 'customers', 'locations', 'inventory_levels', 'inventory_items', 'events'}
self.store_2_streams = {'abandoned_checkouts', 'collects', 'metafields', 'transactions', 'order_refunds', 'products', 'locations', 'inventory_levels', 'inventory_items', 'events'}
# removed 'abandoned_checkouts' from store 2 streams, as per the Doc:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put back, see previous comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included abandoned_checkouts stream

msg="The fields sent to the target are not the automatic fields"
)

# Verify that all replicated records have unique primary key values.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition

Comment thread tests/test_discovery.py
if md_entry['breadcrumb'] != []:
actual_fields.append(md_entry['breadcrumb'][1])
# Verify there are no duplicate/conflicting metadata entries.
self.assertEqual(len(actual_fields), len(set(actual_fields)), msg="There are duplicate entries in the fields of '{}' stream".format(stream))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition

Comment thread tests/test_start_date.py Outdated
first_sync_start_date = self.get_properties()["start_date"]
second_sync_start_date = self.start_date

# loop over minimum bookmark and the start date/state file date for each syncs to verify
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original implementation here was very difficult to follow. These changes are helpful, but can this be updated to conform to current best practices? See https://github.com/singer-io/tap-helpscout/blob/ad2b6192a5f5fad8c5bd0573cb38bf38bd5962dd/tests/test_helpscout_start_date.py#L109-L122

Copy link
Copy Markdown
Contributor Author

@hpatel41 hpatel41 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first 2 assertions are already included in our test case at line no. 141 and 147. Added assertion of replication key-values synced is greater than or equal to the start date.

@hpatel41 hpatel41 requested a review from kspeer825 April 11, 2022 10:23
Comment thread tests/test_start_date.py
Comment on lines +182 to +183
for record_replication_key in record_replication_keys:
self.assertGreaterEqual(record_replication_key, start_date)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the try except and assertion above are unnecessary. The minimum replication key value is covered by this assertion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary assertion.

@hpatel41 hpatel41 requested a review from kspeer825 April 11, 2022 13:46
@hpatel41 hpatel41 changed the base branch from crest-work to api-sdk-version-change-and-fields-addition April 12, 2022 07:02
@hpatel41 hpatel41 changed the base branch from api-sdk-version-change-and-fields-addition to crest-work April 12, 2022 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants